package channel

import (
	"github.com/project-flogo/core/data/coerce"
)

type Settings struct {
	Initial int64 `md:"initial"`
}

type Input struct {
	Op string `md:"op"`
}

func (r *Input) ToMap() map[string]interface{} {
	return map[string]interface{}{
		"op": r.Op,
	}
}

func (r *Input) FromMap(values map[string]interface{}) error {
	var err error
	r.Op, err = coerce.ToString(values["op"])
	if err != nil {
		return err
	}

	return nil
}

type Output struct {
	Count int64 `md:"count"`
}

func (r *Output) ToMap() map[string]interface{} {
	return map[string]interface{}{
		"count": r.Count,
	}
}

func (r *Output) FromMap(values map[string]interface{}) error {
	var err error
	r.Count, err = coerce.ToInt64(values["count"])
	if err != nil {
		return err
	}
	return nil
}
